package com.example.makerspace.dao;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.makerspace.domain.ExpertTaskStateDO;
import com.example.makerspace.mapper.ExpertTaskStateMapper;
import com.example.makerspace.mapper.ImsingleMapper;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;

@Component
public class ExpertTaskStateDAO extends  BaseDAO<ExpertTaskStateDO> {
    @Resource
    private ExpertTaskStateMapper expertTaskStateMapper;

    @PostConstruct
    public void init(){
        this.mapper = expertTaskStateMapper;
    }

    public ExpertTaskStateDO selectByTaskIdAndUserName(Integer taskId, String username) {
        QueryWrapper<ExpertTaskStateDO> wrapper = new QueryWrapper<>();
        wrapper.eq("task_id",taskId).eq("username",username);
        return mapper.selectOne(wrapper);
    }


    public void deleteByTaskIdAndUserName(Integer taskId, String username) {
        QueryWrapper<ExpertTaskStateDO> wrapper = new QueryWrapper<>();
        wrapper.eq("task_id",taskId).eq("username",username);
        mapper.delete(wrapper);
    }
}
